cd "C:\Users\ot3\Documents\CRFertility"

****************************************************************
***Tables and Figures Using State-Level Vital Statistics Data***
****************************************************************

***Figure 1: Trends in GFR Levels and Differences***
use frate_working_state, clear

*levels
collapse (mean) brate [aweight=fpop], by(year black south)

twoway connect brate year if  black==1 & south==1, lpattern(solid) lcolor(black) msymbol(square) mcolor(black) ||  ///
connect brate year if black==0 & south==1, lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7)  || ///
connect brate year if black==1 & south==0, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10)  ||  ///
connect brate year if black==0 & south==0, lpattern(longdash_dot)  lcolor(gs13) msymbol(diamond) mcolor(gs13) xline(1964, lcolor(black)) ///
subtitle(A: General Fertility Rates) xtitle(Year) ytitle(General Fertility Rate) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) legend(label(1 "Southern Black") label(2 "Southern White")  label(3 "Northern Black") label(4 "Northern White") rows(2))   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(levs, replace) 


*differences
reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black)  || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) xline(1964, lcolor(black)) ///
subtitle(B: General Fertility Rate Differences) xtitle(Year) ytitle(Difference in General Fertility Rate) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) legend(label(1 "Southern Black - Southern White" ) label(2 "Northern Black - Northern White") rows(2))   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(diff, replace)

graph combine levs.gph diff.gph, xsize(16) ysize(9)  title("Figure 1: Fertility Rates by Year, Race and Region") graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) 




*Figure A3: Alternate regional definitions 
*baseline, where border region is part of north
use frate_working_state, clear
collapse (mean) brate [aweight=fpop], by(year black south)

reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small) || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1964, lcolor(black)) ///
subtitle(A: Baseline) xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975) legend(off)    ///
legend(label(1 "Southern Black - Southern White" ) label(2 "Northern Black - Northern White") rows(1)) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(baseline, replace)


*border region is part of south
use frate_working_state, clear
replace south=1 if border==1
collapse (mean) brate [aweight=fpop], by(year black south)

reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small) || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1964, lcolor(black)) ///
subtitle(B: Border Region Included in South) xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975) legend(off)   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(borderwithsouth, replace)

*border region excluded
use frate_working_state, clear

drop if border==1
collapse (mean) brate [aweight=fpop], by(year black south)

reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small) || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1964, lcolor(black)) ///
subtitle(C: Border Region Excluded) xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975) legend(off)   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(borderexcluded, replace) 


*north is rust belt only
use frate_working_state, clear

keep if south==1 | inlist(fipsst, 17,18,26,29,36,39,42) //IL, IN, MI, MO, NY, OH, PA
collapse (mean) brate [aweight=fpop], by(year black south)

reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black)  msize(small) || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1964, lcolor(black)) ///
subtitle(D: North Restricted to Rust-Belt Only) xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975) legend(off)   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(rustbelt, replace) 


grc1leg baseline.gph borderwithsouth.gph borderexcluded.gph rustbelt.gph, rows(2)   ycommon subtitle("Figure A3: Alternative Regional Definitions") graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  //change aspect ratio to .55 manually






*Figure A4: State by state
*All southern states				 
use frate_working_state, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(All States) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(All, replace) 

*Alabama
use frate_working_state if fipsst==1, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Alabama) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(AL, replace) 

*Arkansas
use frate_working_state if fipsst==5, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Arkansas) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(AR, replace) 

*Florida
use frate_working_state if fipsst==12, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Florida) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(FL, replace) 

*Georgia
use frate_working_state if fipsst==13, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Georgia) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(GA, replace)

*Louisiana
use frate_working_state if fipsst==22, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Louisiana) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(LA, replace)

*Mississippi
use frate_working_state if fipsst==28, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Mississippi) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(MS, replace)

*North Carolina
use frate_working_state if fipsst==37, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(North Carolina) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(NC, replace)

*South Carolina
use frate_working_state if fipsst==45, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(South Carolina) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(SC, replace)

*Tennessee
use frate_working_state if fipsst==47, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Tennessee) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(TN, replace)

*Texas
use frate_working_state if fipsst==48, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Texas) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(TX, replace)

*Virginia
use frate_working_state if fipsst==51, clear
collapse (mean) brate [aweight=fpop], by(year black )
reshape wide brate, i(year) j(black)
g bs_ws=brate1-brate0
twoway connect bs_ws year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) xline(1964, lcolor(black)) ///
subtitle(Virginia) xtitle(Year) ytitle(B-W Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45))    ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(VA, replace)


graph combine All.gph AL.gph AR.gph FL.gph GA.gph  LA.gph MS.gph NC.gph  SC.gph TN.gph TX.gph VA.gph ,  xsize(15) ysize(10)  graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) title(Figure A4: State Level Results)





*Table A1 and Figure A6: 'triple-diff' models
*levels
use frate_working_state, clear
collapse (mean) brate [aweight=fpop], by(year black south)

g blackXsouth=black*south
foreach y of numlist 1955/1975 {
g Y`y'=year==`y'
g BxY`y'=black*Y`y'
g SxY`y'=south*Y`y'
g BxSxY`y'=black*south*Y`y'
}


#delimit ;
reg brate  black south blackXsouth
Y1955 Y1956 Y1957 Y1958 Y1959 Y1960 Y1961 Y1962 Y1963 Y1965 Y1966 Y1967 Y1968 Y1969 Y1970 Y1971 Y1972 Y1973 Y1974 Y1975
BxY1955 BxY1956 BxY1957 BxY1958 BxY1959 BxY1960 BxY1961 BxY1962 BxY1963 BxY1965 BxY1966 BxY1967 BxY1968 BxY1969 BxY1970 BxY1971 BxY1972 BxY1973 BxY1974 BxY1975
SxY1955 SxY1956 SxY1957 SxY1958 SxY1959 SxY1960 SxY1961 SxY1962 SxY1963 SxY1965 SxY1966 SxY1967 SxY1968 SxY1969 SxY1970 SxY1971 SxY1972 SxY1973 SxY1974 SxY1975
BxSxY1955 BxSxY1956 BxSxY1957 BxSxY1958 BxSxY1959 BxSxY1960 BxSxY1961 BxSxY1962 BxSxY1963 BxSxY1965 BxSxY1966 BxSxY1967 BxSxY1968 BxSxY1969 BxSxY1970 BxSxY1971 BxSxY1972 BxSxY1973 BxSxY1974 BxSxY1975;

outreg2 using T1,  keep(_all) dec(1)  nose  replace ;

matrix res=[1955, _b[BxSxY1955] \ 
			1956, _b[BxSxY1956] \
			1957, _b[BxSxY1957] \
			1958, _b[BxSxY1958] \
			1959, _b[BxSxY1959] \
			1960, _b[BxSxY1960] \
			1961, _b[BxSxY1961] \
			1962, _b[BxSxY1962] \
			1963, _b[BxSxY1963] \
			1964, 0 \
			1965, _b[BxSxY1965] \
			1966, _b[BxSxY1966] \
			1967, _b[BxSxY1967] \
			1968, _b[BxSxY1968] \
			1969, _b[BxSxY1969] \
			1970, _b[BxSxY1970] \
			1971, _b[BxSxY1971] \
			1972, _b[BxSxY1972] \
			1973, _b[BxSxY1973] \
			1974, _b[BxSxY1974] \
			1975, _b[BxSxY1975]] ;
#delimit cr
			 
svmat res
keep res1 res2
keep in 1/21
rename res1 year
rename res2 ddd

twoway connect ddd year, xline(1964, lcolor(black)) mcolor(black) msize(small) ///
subtitle("Figure A6: Triple Difference Estimates") xtitle(Year) ytitle(Coefficients on Black x South x Year) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) legend(off)  saving(levels, replace)  ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))





*Figure A1: Age-Specific GFRs
use frate_working_age, clear

reshape wide brate, i(year south black) j(magecat)
reshape wide brate*, i(year south) j(black)
reshape wide brate*, i(year) j(south ) 
g bs_ws_age1=brate111-brate101
g bs_ws_age2=brate211-brate201
g bs_ws_age3=brate311-brate301
g bs_ws_age4=brate411-brate401
g bs_ws_age5=brate511-brate501
g bs_ws_age6=brate611-brate601

g bn_wn_age1=brate110-brate100
g bn_wn_age2=brate210-brate200
g bn_wn_age3=brate310-brate300
g bn_wn_age4=brate410-brate400
g bn_wn_age5=brate510-brate500
g bn_wn_age6=brate610-brate600



twoway connect bn_wn_age1 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age1 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG1, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 15-19)

twoway connect bn_wn_age2 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age2 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG2, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 20-24)

twoway connect bn_wn_age3 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age3 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG3, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 25-29)

twoway connect bn_wn_age4 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age4 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG4, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 30-34)

twoway connect bn_wn_age5 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age5 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG5, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 35-39)

twoway connect bn_wn_age6 year, lpattern(dot) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(vsmall) lwidth(vthin)  || ///
connect bs_ws_age6 year, lpattern(dash) lpattern(dash) lcolor(gs7) msymbol(triangle) mcolor(gs7) msize(vsmall) lwidth(vthin) ///
 xline(1964, lcolor(black))  xtitle(Year) ytitle(Difference in GFR) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(AG6, replace) ///
legend(label(1 "Northern Black - Northern White") label(2 "Southern Black - Southern White") rows(1) symx(*.45) symy(*.45) size(*.55) keygap(*.2)) subtitle(Ages 40-44) 

grc1leg  AG1.gph AG2.gph AG3.gph AG4.gph AG5.gph AG6.gph, graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))   rows(2) subtitle("Figure A1: Age-Specific General Fertility Rate Differences") 

	 
	 
	 
	 

***************************************************
***Figures using county-level fertility measures***
***************************************************
*Figure A2: Map of county-level changes
use frate_working_county, clear
keep if year==1964 | year==1969 
keep fips black year brate 

reshape wide brate, i(fips black) j(year)
reshape wide brate*, i(fips ) j(black)

g Diff1964=brate19641-brate19640
g Diff1969=brate19691 -brate19690
g CinDiff= Diff1964-Diff1969
g PctCinDiff= (Diff1964-Diff1969)/Diff1964
keep fips brate19641 brate19640 brate19690 brate19691 Diff1964 Diff1969 CinDiff PctCinDiff

foreach x of varlist brate19641 brate19640 brate19690 brate19691 Diff1964 Diff1969 CinDiff {
replace `x'=round(`x')
} 
save ForMap, replace

use cntydb, clear
duplicates drop FIPS, force
rename FIPS fips
destring fips, replace
rename countyfip _ID
merge 1:1 fips using ForMap

tostring fips, format(%05.0f) replace
g fipsst=substr(fips, 1,2)
destring fipsst, replace
keep if inlist(fipsst, 1, 5, 12, 13,  22, 28, 37, 45, 47, 48, 51) 

sum CinDiff, det

spmap  CinDiff  using cntycoords , id(_ID) clmethod(custom)  clbreaks(-113 0 5 10 15 20 25 30 35 40 45 50 253) fcolor(Greys2) ndpattern(dot) ndocolor(black) title("Figure A2: County-Level Convergence in Black-White GFR Differential")   ///
legend(order(11 10 9 8 7 6 5 4 3 2 1) label(1 "no data") label(2 "less than 0") label(3 "0 to 5") label(4 "5 to 10") label(5 "10 to 15") label(6 "15 to 20") label(7 "20 to 25") label(8 "25 to 30") label(9 "35 to 40") label(10 "45 to 50") label(11 "50 or more")) saving(map, replace)
																																							   
graph export "C:\Users\ot3\Documents\CRFertility\map.png", replace	



*Correlatoin with slave density quoted in appendix text
use frate_working_county, clear
merge m:1 fips using slavepops  
drop if _merge==2
drop _merge

keep fips black year brate fpop pslave1860 

keep if year==1964 | year==1969 
reshape wide brate fpop, i(fips black) j(year)
reshape wide brate* fpop*, i(fips ) j(black)
g fgap_change=(brate19641-brate19640)-(brate19691 -brate19690)

corr pslave1860 fgap_change




*Figure A5: Counties with non-black minorities excluded
use frate_working_county, clear

*levels
collapse (mean) brate [aweight=fpop], by(year black south)
reshape wide brate, i(year south) j(black)
reshape wide brate*, i(year) j(south)
g bs_ws=brate11-brate01
g bn_wn=brate10-brate00

twoway  connect bs_ws year, lpattern(solid) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black)  || ///
connect bn_wn year, lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) xline(1964, lcolor(black)) ///
subtitle("Figure A5: Trends in GFR Differences Excluding Counties with > 1% Non-Black Minorities", size(small)) xtitle(Year, size(small)) ytitle(Difference in General Fertility Rate, size(small)) xtick(1955(5)1975) xlabel(1955(5)1975,  angle(45)) legend(label(1 "Southern Black - Southern White" ) label(2 "Northern Black - Northern White") rows(2)) xsize(4) ysize(3)  ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(diff, replace)






*********************************************************************
***Tables and Figures Using Completed Fertility Measures in Census***
*********************************************************************
*Figure 2A: Completed Fertility Trends
use census_compfer_clean, clear
keep if bornsouth==livesouth
collapse (mean) chborn  [aweight=perwt], by(livesouth black cohort)


*differences
reshape wide chborn, i(cohort livesouth) j(black)
reshape wide chborn*, i(cohort) j(livesouth)
g bs_ws=chborn11-chborn01
g bn_wn=chborn10-chborn00


twoway connect bs_ws cohort, lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small)  || ///
connect bn_wn cohort, lpattern(dash) lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1929 1944, lcolor(black) lpattern(dot))  ///
subtitle(A: Black-White Differences in Completed Fertility) xtitle(Cohort) ytitle(Difference in Completed Fertility) xtick(1920(5)1946) xlabel(1920(5)1946)  legend(off) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(diff, replace)   


*Figure 2B: Distributions
use census_compfer_clean, clear
keep if bornsouth==livesouth	 

hist chborn if black==1 & livesouth==1 & cohort>=1925 & cohort<=1930 [fweight=perwt], disc subtitle("Southern Black Women, 1925-1930 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs10)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(sbpre, replace) 
hist chborn if black==1 & livesouth==1 & cohort>=1941 & cohort<=1946 [fweight=perwt], disc subtitle("Southern Black Women, 1941-1946 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs10)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(sbpost, replace) 
hist chborn if black==0 & livesouth==1 & cohort>=1925 & cohort<=1930 [fweight=perwt], disc subtitle("Southern White Women, 1925-1930 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs14)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(swpre, replace) 
hist chborn if black==0 & livesouth==1 & cohort>=1941 & cohort<=1946 [fweight=perwt], disc subtitle("Southern White Women, 1941-1946 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs14)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(swpost, replace) 
graph combine sbpre.gph sbpost.gph , rows(1) ycommon   graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(black, replace) nodraw
graph combine swpre.gph swpost.gph, rows(1) ycommon   graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(white, replace) nodraw
graph combine black.gph white.gph, rows(2) subtitle(B: Changes in Completed Fertility Distributions) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(dist, replace)
	 

*must add arrows to part A manually
graph combine diff.gph dist.gph, xsize(16) ysize(9)  graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) title("Figure 2: Relative Changes in Completed Fertility") 



	 
	 
*Table A2 and Figure A7: triple-diffs for completed fertility
use census_compfer_clean, clear
keep if bornsouth==livesouth	
rename bornsouth south


g blackXsouth=black*south
foreach c of numlist 1920/1946 {
g C`c'=cohort==`c'
g BxC`c'=black*C`c'
g SxC`c'=south*C`c'
g BxSxC`c'=black*south*C`c'
}

#delimit ;
reg chborn  black south blackXsouth
C1920 C1921 C1922 C1923 C1924 C1925 C1926 C1927 C1928 C1929 C1930 C1932 C1933 C1934 C1936 C1937 C1938 C1939 C1940 C1941 C1942 C1943 C1944 C1945 C1946 
BxC1920 BxC1921 BxC1922 BxC1923 BxC1924 BxC1925 BxC1926 BxC1927 BxC1928 BxC1929 BxC1930 BxC1931 BxC1932 BxC1933 BxC1934 BxC1936 BxC1937 BxC1938 BxC1939 BxC1940 BxC1941 BxC1942 BxC1943 BxC1944 BxC1945 BxC1946
SxC1920 SxC1921 SxC1922 SxC1923 SxC1924 SxC1925 SxC1926 SxC1927 SxC1928 SxC1929 SxC1930 SxC1931 SxC1932 SxC1933 SxC1934 SxC1936 SxC1937 SxC1938 SxC1939 SxC1940 SxC1941 SxC1942 SxC1943 SxC1944 SxC1945 SxC1946
BxSxC1920 BxSxC1921 BxSxC1922 BxSxC1923 BxSxC1924 BxSxC1925 BxSxC1926 BxSxC1927 BxSxC1928 BxSxC1929 BxSxC1930 BxSxC1931 BxSxC1932 BxSxC1933 BxSxC1934 BxSxC1936 BxSxC1937 BxSxC1938 BxSxC1939 BxSxC1940 BxSxC1941 BxSxC1942 BxSxC1943 BxSxC1944 BxSxC1945 BxSxC1946
[aweight=perwt], cluster(statefip);

outreg2 using T1,  keep(_all) dec(3)  replace ;

matrix res=[1920, _b[BxSxC1920], _se[BxSxC1920] \ 
			1921, _b[BxSxC1921], _se[BxSxC1921] \
			1922, _b[BxSxC1922], _se[BxSxC1922]\
			1923, _b[BxSxC1923], _se[BxSxC1923] \
			1924, _b[BxSxC1924], _se[BxSxC1924] \
			1925, _b[BxSxC1925], _se[BxSxC1925] \
			1926, _b[BxSxC1926], _se[BxSxC1926] \
			1927, _b[BxSxC1927], _se[BxSxC1927] \
			1928, _b[BxSxC1928], _se[BxSxC1928] \
			1929, _b[BxSxC1929], _se[BxSxC1929] \
			1930, _b[BxSxC1930], _se[BxSxC1930] \
			1931, _b[BxSxC1931], _se[BxSxC1931] \
			1932, _b[BxSxC1932], _se[BxSxC1932] \
			1933, _b[BxSxC1933], _se[BxSxC1933] \
			1934, _b[BxSxC1934], _se[BxSxC1934] \
			1935, 0, 0 \
			1936, _b[BxSxC1936], _se[BxSxC1936] \
			1937, _b[BxSxC1937], _se[BxSxC1937] \
			1938, _b[BxSxC1938], _se[BxSxC1938] \
			1939, _b[BxSxC1939], _se[BxSxC1939] \
			1940, _b[BxSxC1940], _se[BxSxC1940] \
			1941, _b[BxSxC1941], _se[BxSxC1941] \
			1942, _b[BxSxC1942], _se[BxSxC1942] \
			1943, _b[BxSxC1943], _se[BxSxC1943] \
			1944, _b[BxSxC1944], _se[BxSxC1944] \
			1945, _b[BxSxC1945], _se[BxSxC1945] \
			1946, _b[BxSxC1946], _se[BxSxC1946]] ;	
			
#delimit cr
			 
svmat res
keep res1 res2 res3
keep in 1/27
rename res1 cohort
rename res2 ddd
rename res3 se
g min=ddd-1.67*se
g max=ddd+1.67*se

twoway rcap  min max cohort, lcolor(gs12) || ///
connect ddd cohort, lcolor(black) mcolor(black) msize(small) ///
title("Figure A7: Completed Fertility Triple-Difference Results") xtitle(Cohort) ytitle(Coefficients on Black x South X Cohort) xtick(1920(5)1946) xlabel(1920(5)1946) legend(off) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))




*Figure A8: CPS replication of Completed Fertility Trends
*A: Mean Trends
use cpsclean, clear
count 
collapse (mean) frever  [aweight=wtfinl], by(south black cohort)


*differences
reshape wide frever, i(cohort south) j(black)
reshape wide frever*, i(cohort) j(south)
g bs_ws=frever11-frever01
g bn_wn=frever10-frever00


twoway connect bs_ws cohort, lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small)  || ///
connect bn_wn cohort, lpattern(dash) lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1929 1944, lcolor(black) lpattern(dot))  ///
subtitle("A: Black-White Differences in Completed Fertility") xtitle(Cohort) ytitle(Difference in Completed Fertility) xtick(1920(5)1960) xlabel(1920(5)1960)  legend(off) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(diff, replace)   


*B: Distributions
use cpsclean, clear
replace wtfinl=round(wtfinl)

hist  frever if black==1 & south==1 & cohort>=1925 & cohort<=1930 [fweight=wtfinl], disc subtitle("Southern Black Women, 1925-1930 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs10)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(sbpre, replace) 
hist  frever if black==1 & south==1 & cohort>=1945 & cohort<=1950 [fweight=wtfinl], disc subtitle("Southern Black Women, 1945-1950 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs10)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(sbpost, replace) 
hist  frever if black==0 & south==1 & cohort>=1925 & cohort<=1930 [fweight=wtfinl], disc subtitle("Southern White Women, 1925-1930 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs14)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(swpre, replace) 
hist  frever if black==0 & south==1 & cohort>=1945 & cohort<=1950 [fweight=wtfinl], disc subtitle("Southern White Women, 1945-1950 Cohorts") xlabel(0(1)12) xtitle("") ytitle("") color(black) fcolor(gs14)  lwidth(vthin) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(swpost, replace) 
graph combine sbpre.gph sbpost.gph , rows(1) ycommon   graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(black, replace) nodraw
graph combine swpre.gph swpost.gph, rows(1) ycommon   graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(white, replace) nodraw
graph combine black.gph white.gph, rows(2) subtitle("B: Changes in Completed Fertility Distributions") graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(dist, replace)
	 
graph combine diff.gph dist.gph, xsize(16) ysize(9)  graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) title("Figure A8: CPS Replication of Completed Fertility Trends") 




	 
*Figure A9: Migration robustness
*A: by birth
use census_compfer_clean, clear
collapse (mean) chborn  [aweight=perwt], by(bornsouth black cohort)

reshape wide chborn, i(cohort bornsouth) j(black)
reshape wide chborn*, i(cohort) j(bornsouth)
g bs_ws=chborn11-chborn01
g bn_wn=chborn10-chborn00

twoway connect bs_ws cohort, lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small)  || ///
connect bn_wn cohort, lpattern(dash) lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1929 1944, lcolor(black) lpattern(dot))  ///
subtitle(A: By Region of Birth) xtitle(Cohort) ytitle(Difference in Completed Fertility) xtick(1920(5)1946) xlabel(1920(5)1946)   ///
legend(label(1 "Southern Born Black - Southern Born White") label(2 "Northern Born Black - Northern Born White" ) rows(2))   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(birth, replace)  

*B: by residence
use census_compfer_clean, clear
collapse (mean) chborn  [aweight=perwt], by(livesouth black cohort)

reshape wide chborn, i(cohort livesouth) j(black)
reshape wide chborn*, i(cohort) j(livesouth)
g bs_ws=chborn11-chborn01
g bn_wn=chborn10-chborn00

twoway connect bs_ws cohort, lpattern(solid) lcolor(black) msymbol(triangle) mcolor(black) msize(small)  || ///
connect bn_wn cohort, lpattern(dash) lpattern(dash) lcolor(gs10) msymbol(circle) mcolor(gs10) msize(small) xline(1929 1944, lcolor(black) lpattern(dot))  ///
subtitle(B: By Region of Residence) xtitle(Cohort) ytitle(Difference in Completed Fertility) xtick(1920(5)1946) xlabel(1920(5)1946)  ///
legend(label(1 "Southern Residing Black - Southern Residing White") label(2 "Northern Residing Black - Northern Residing White" ) rows(2))   ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(resid, replace) 

*C: southern born blacks disaggregated by migration status
use census_compfer_clean, clear
keep if black==1 
collapse (mean) chborn   [aweight=perwt], by(cohort bornsouth livesouth)

twoway connect chborn cohort if bornsouth==1 & livesouth==1, lpattern(solid) lcolor(black) msymbol(circle) mcolor(black) msize(small) ///
	|| connect chborn cohort if bornsouth==1 & livesouth==0, lpattern(dash) lcolor(gs10) msymbol(triangle) mcolor(gs10) msize(small) xline(1929 1944, lcolor(black) lpattern(dot))  ///
	subtitle(C: By Migration Status among Southern-Born Blacks) xtitle(Cohort) ytitle(Completed Fertility Levels) xtick(1920(5)1946) xlabel(1920(5)1946)  ///
	legend(label(1 "Born South, Live South (stayers)") label(2 "Born South, Live North (leavers)" )  rows(2)) ///
	graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) saving(migrant, replace) 
 
graph combine birth.gph resid.gph migrant.gph, rows(1)  xsize(20) ysize(7) subtitle("Figure A9: Completed Fertility and Inter-Regional Migration") graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) 

	
	
	
	
**********************************************************
***Tables using Census Based Measures of a Recent Birth***
**********************************************************

*Table 1: Comparing Census and Vital Stats GFR Measures
*Vitals
use frate_working_state, clear
collapse (mean) brate [aweight=fpop], by(year black south)

sum brate if black==1 & south==1 & year==1960 
sum brate if black==1 & south==1 & year==1970 

sum brate if black==0 & south==1 & year==1960 
sum brate if black==0 & south==1 & year==1970 

sum brate if black==1 & south==0 & year==1960 
sum brate if black==1 & south==0 & year==1970 

sum brate if black==0 & south==0 & year==1960 
sum brate if black==0 & south==0 & year==1970 

*Census Measure
use census_selection_clean, clear
replace newbirth=newbirth*1000

sum newbirth if black==1 & south==1 & year==1960 [aweight=perwt]
sum newbirth if black==1 & south==1 & year==1970 [aweight=perwt]
 
sum newbirth if black==0 & south==1 & year==1960 [aweight=perwt]
sum newbirth if black==0 & south==1 & year==1970 [aweight=perwt]

sum newbirth if black==1 & south==0 & year==1960 [aweight=perwt]
sum newbirth if black==1 & south==0 & year==1970 [aweight=perwt]

sum newbirth if black==0 & south==0 & year==1960 [aweight=perwt]
sum newbirth if black==0 & south==0 & year==1970 [aweight=perwt]



*Table A3: Vitals versus Census with IMR Adjustment
use "C:\Users\ot3\Documents\CRFertility\Mortality\aer_baileybacon", clear  //from https://www.aeaweb.org/articles?id=10.1257/aer.20120070&within%5Btitle%5D=on&within%5Babstract%5D=on&within%5Bauthor%5D=on&within%5BjelCode%5D=0&journal=1&from=a&q=bailey&from=j
g south= inlist(stfips, 1, 5, 12, 13, 22, 28, 37, 45, 47, 48, 51) 
keep south year imr_w imr_nw bwt_w bwt_nw 

*SB
sum imr_nw if year==1960 & south==1 [aweight=bwt_nw]
sum imr_nw if year==1970 & south==1 [aweight=bwt_nw]
*SW
sum imr_w if year==1960 & south==1 [aweight=bwt_w]
sum imr_w if year==1970 & south==1 [aweight=bwt_w]
*NB
sum imr_nw if year==1960 & south==0 [aweight=bwt_nw]
sum imr_nw if year==1970 & south==0 [aweight=bwt_nw]
*NW
sum imr_w if year==1960 & south==0 [aweight=bwt_w]
sum imr_w if year==1970 & south==0 [aweight=bwt_w]






***Figure 3: Heterogeneity***
*SB
use census_selection_clean, clear
drop if south!=bornsouth
replace newbirth=newbirth*1000

*ed
qui reg newbirth y1969  if black==1 & south==1 [aweight=perwt], cluster(statefip)
matrix res=[_b[y1969]]
qui reg newbirth y1969  if black==1 & south==1 & educ<=8 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969  if  black==1 & south==1 & educ>=9 & educ<=12 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969  if black==1 & south==1 & educ>12  [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]

*Existing kids
qui reg newbirth y1969 if black==1 & south==1 & nchild==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969 if black==1 & south==1 & nchild==2 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969 if black==1 & south==1 & nchild<=4 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969 if black==1 & south==1 & nchild>=5 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]

*Farm
qui reg newbirth y1969 if black==1 & south==1 & farm==0 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969 if black==1 & south==1 & farm==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]
qui reg newbirth y1969 if black==1 & south==1 & sharecrop==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[y1969] ]

svmat res
keep res*
keep in 1
rename res1 all
rename res2 lowed
rename res3 meded
rename res4 highed
rename res5 onekid
rename res6 twokid
rename res7 threekid
rename res8 fourpluskid
rename res9 nonfarm
rename res10 farm
rename res11 sharecrop

graph bar (asis)  lowed meded highed onekid twokid threekid fourpluskid nonfarm farm sharecrop,  ///
bar(1, fcolor(gs8) lcolor(black)) bar(2, fcolor(gs8) lcolor(black))	bar(3, fcolor(gs8) lcolor(black))  bar(4, fcolor(gs8) lcolor(black)) bar(5, fcolor(gs8) lcolor(black)) bar(6, fcolor(gs8) lcolor(black)) bar(7, fcolor(gs8) lcolor(black)) bar(8, fcolor(gs8) lcolor(black)) bar(9, fcolor(gs8) lcolor(black)) bar(10, fcolor(gs8) lcolor(black)) blabel(name, margin(tiny) orientation(vertical) pos(north)) legend(off) ///
subtitle(A: Level Changes among Southern Blacks) ytitle(Level Change) yline(-38.3, lcolor(black) lpattern(dash)) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(SB, replace)




*BW Difference in South
clear all
use census_selection_clean, clear
drop if south!=bornsouth
replace newbirth=newbirth*1000


*ed
qui reg newbirth black y1969 blackXy1969 if south==1 [aweight=perwt], cluster(statefip)
matrix res=[_b[blackXy1969]]
qui reg newbirth black y1969 blackXy1969  if south==1 & educ<=8 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969  if  south==1 & educ>=9 & educ<=12 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969  if south==1 & educ>12  [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]

*Existing kids
qui reg newbirth black y1969 blackXy1969 if  south==1 & nchild==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969 if south==1 & nchild==2 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969 if  south==1 & nchild<=4 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969 if  south==1 & nchild>=5 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]

*Farm
qui reg newbirth black y1969 blackXy1969 if  south==1 & farm==0 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969 if  south==1 & farm==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]
qui reg newbirth black y1969 blackXy1969 if south==1 & sharecrop==1 [aweight=perwt], cluster(statefip)
matrix res=[res, _b[blackXy1969] ]

svmat res
keep res*
keep in 1
rename res1 all
rename res2 lowed
rename res3 meded
rename res4 highed
rename res5 onekid
rename res6 twokid
rename res7 threekid
rename res8 fourpluskid
rename res9 nonfarm
rename res10 farm
rename res11 sharecrop

graph bar (asis)  lowed meded highed onekid twokid threekid fourpluskid nonfarm farm sharecrop,  ///
bar(1, fcolor(gs8) lcolor(black)) bar(2, fcolor(gs8) lcolor(black))	bar(3, fcolor(gs8) lcolor(black))  bar(4, fcolor(gs8) lcolor(black)) bar(5, fcolor(gs8) lcolor(black)) bar(6, fcolor(gs8) lcolor(black)) bar(7, fcolor(gs8) lcolor(black)) bar(8, fcolor(gs8) lcolor(black)) bar(9, fcolor(gs8) lcolor(black)) bar(10, fcolor(gs8) lcolor(black)) blabel(name, margin(tiny) orientation(vertical) pos(north)) legend(off) ///
subtitle(B: Black-White Convergence) ytitle(Convergence) yline(-13.15, lcolor(black) lpattern(dash)) /// ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  saving(gap, replace)

graph combine SB.gph gap.gph, rows(2)  ysize(22) xsize(18) graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white)) title(Figure 3: Heterogeneity)




***Appendix Table A4: Heterogeneity***
*level changes among southern blacks (Panel A)
clear all
use census_selection_clean, clear
drop if south!=bornsouth
keep if black==1 & south==1
replace newbirth=newbirth*1000

*all
qui reg newbirth y1969  [aweight=perwt], cluster(statefip)
est sto all

*ed
qui reg newbirth y1969  if educ<=8 [aweight=perwt], cluster(statefip)
est sto lowed
qui reg newbirth y1969 if  educ>=9 & educ<=12 [aweight=perwt], cluster(statefip)
est sto meded
qui reg newbirth y1969  if educ>12  [aweight=perwt], cluster(statefip)
est sto highed

*Existing kids
qui reg newbirth y1969 if nchild==1 [aweight=perwt], cluster(statefip)
est sto kid1
qui reg newbirth y1969 if nchild==2 [aweight=perwt], cluster(statefip)
est sto kid2
qui reg newbirth y1969 if  nchild==3 [aweight=perwt], cluster(statefip)
est sto kid3
qui reg newbirth y1969 if  nchild>=4 [aweight=perwt], cluster(statefip)
est sto kid4plus


*Farm
qui reg newbirth y1969 if   farm==0 [aweight=perwt], cluster(statefip)
est sto nofarm
qui reg newbirth y1969 if  farm==1 [aweight=perwt], cluster(statefip)
est sto farm
qui reg newbirth y1969 if  sharecrop==1 [aweight=perwt], cluster(statefip)
est sto sharecrop

outreg2 [*] using T1,  keep(y1969) dec(3) nocons nor2 replace 



*BW Difference in South (Panel B)
clear all
use census_selection_clean, clear
drop if south!=bornsouth
keep if south==1
replace newbirth=newbirth*1000

*all
qui reg newbirth black y1969 blackXy1969  [aweight=perwt], cluster(statefip)
est sto all

*ed
qui reg newbirth black y1969 blackXy1969  if educ<=8 [aweight=perwt], cluster(statefip)
est sto lowed
qui reg newbirth black y1969 blackXy1969  if  educ>=9 & educ<=12 [aweight=perwt], cluster(statefip)
est sto meded
qui reg newbirth black y1969 blackXy1969  if educ>12  [aweight=perwt], cluster(statefip)
est sto highed

*Existing kids
qui reg newbirth black y1969 blackXy1969 if nchild==1 [aweight=perwt], cluster(statefip)
est sto kid1
qui reg newbirth black y1969 blackXy1969 if nchild==2 [aweight=perwt], cluster(statefip)
est sto kid2
qui reg newbirth black y1969 blackXy1969 if  nchild==3 [aweight=perwt], cluster(statefip)
est sto kid3
qui reg newbirth black y1969 blackXy1969 if  nchild>=4 [aweight=perwt], cluster(statefip)
est sto kid4plus


*Farm
qui reg newbirth black y1969 blackXy1969 if   farm==0 [aweight=perwt], cluster(statefip)
est sto nofarm
qui reg newbirth black y1969 blackXy1969 if  farm==1 [aweight=perwt], cluster(statefip)
est sto farm
qui reg newbirth black y1969 blackXy1969 if  sharecrop==1 [aweight=perwt], cluster(statefip)
est sto sharecrop

outreg2 [*] using T1,  keep(blackXy1969) dec(3) nocons nor2 replace 



*DDD (Panel C))
clear all
use census_selection_clean, clear
drop if south!=bornsouth
replace newbirth=newbirth*1000

qui reg newbirth black##south##y1969 [aweight=perwt], cluster(statefip)
est sto all

*ed
qui reg newbirth black##south##y1969  if educ<=8 [aweight=perwt], cluster(statefip)
est sto lowed
qui reg newbirth black##south##y1969  if   educ>=9 & educ<=12 [aweight=perwt], cluster(statefip)
est sto meded
qui reg newbirth black##south##y1969  if educ>12  [aweight=perwt], cluster(statefip)
est sto highed

*Existing kids
qui reg newbirth black##south##y1969 if  nchild==1 [aweight=perwt], cluster(statefip)
est sto kid1
qui reg newbirth black##south##y1969 if  nchild==2 [aweight=perwt], cluster(statefip)
est sto kid2
qui reg newbirth black##south##y1969 if   nchild<=4 [aweight=perwt], cluster(statefip)
est sto kid3
qui reg newbirth black##south##y1969 if   nchild>=5 [aweight=perwt], cluster(statefip)
est sto kid4plus

*Farm
qui reg newbirth black##south##y1969 if   farm==0 [aweight=perwt], cluster(statefip)
est sto nofarm
qui reg newbirth black##south##y1969 if   farm==1 [aweight=perwt], cluster(statefip)
est sto farm
qui reg newbirth black##south##y1969 if  sharecrop==1 [aweight=perwt], cluster(statefip)
est sto sharecrop

outreg2 [*] using T1, dec(3) nocons nor2 replace 




***Table 2: Effect on kid chars***
use census_selection_clean, clear
drop if south!=bornsouth
keep if bornsouth==1

*BS
foreach x of varlist   higrade8  highfert sharecrop {   
qui reg `x' y1969 if black==1  & newbirth==1 [aweight=perwt], cluster(statefip) 
est sto `x'_sb_m
qui reg `x' y1969 if black==1  & newbirth==0 [aweight=perwt], cluster(statefip)
est sto `x'_sb_nm
qui reg `x' y1969 newbirth newbirthXy1969 if black==1 [aweight=perwt], cluster(statefip)  
est sto `x'_sb_d
*WS
qui reg `x' y1969 if black==0  & newbirth==1 [aweight=perwt], cluster(statefip) 
est sto `x'_sw_m
qui reg `x' y1969 if black==0  & newbirth==0 [aweight=perwt], cluster(statefip)
est sto `x'_sw_nm
qui reg `x' y1969 newbirth newbirthXy1969 if black==0 [aweight=perwt], cluster(statefip)  
est sto `x'_sw_d
*DDD
qui reg `x' black newbirth y1969  blackXy1969 newbirthXblack newbirthXy1969   newbirthXblackXy1969 [aweight=perwt], cluster(statefip)  
est sto `x'_sb_ddd
*Baseline diffs
qui reg `x' black if y1969==0 & newbirth==1 [aweight=perwt], cluster(statefip)  
est sto `x'_basegap
}

outreg2 [*] using T1, dec(3) nocons nor2 replace 






***Appendix A5: Effect on kid chars including North (DDDD)***
use census_selection_clean, clear
drop if south!=bornsouth

*DDDD
foreach x of varlist   higrade8  highfert sharecrop {   
qui reg `x' y1969##newbirth##black##south 			[aweight=perwt], cluster(statefip)  
est sto `x'
}

outreg2 [*] using T1, dec(3) nocons nor2 replace 




***TABLE 3: TWFE***
use census_twfe, clear

sum log_incgap BWGap_hgc if south==1

local demconts="fem0 fem1 c.age1##c.age1##c.age1 c.age0##c.age0##c.age0 " 
local cohort_statechars="c.totpop1960##cohort c.landarea1960##cohort c.pcturban1960##cohort c.mededuc1960##cohort c.medinc1960##cohort c.pctblack1960##cohort"
local depvars="log_incgap BWGap_hgc" 

foreach y of local depvars {
qui areg  `y' BWGap_brate i.cohort `demconts'  if south==1, abs(state_bir) cluster(state_bir)
est sto `y'_s
qui areg  `y' BWGap_brate i.cohort `demconts'  if south==0, abs(state_bir) cluster(state_bir)
est sto `y'_n

qui areg  `y' BWGap_brate i.cohort `demconts' c.cohort#state_bir  if south==1, abs(state_bir) cluster(state_bir)
est sto `y'_s_trends
qui areg  `y' BWGap_brate i.cohort `demconts' c.cohort#state_bir  if south==0, abs(state_bir) cluster(state_bir)
est sto `y'_n_trends

qui areg  `y' BWGap_brate i.cohort `demconts' `cohort_statechars' if south==1, abs(state_bir) cluster(state_bir)
est sto `y'_s_coheffects
qui areg  `y' BWGap_brate i.cohort `demconts' `cohort_statechars' if south==0, abs(state_bir) cluster(state_bir)
est sto `y'_n_coheffects
}

outreg2 [*] using T1, keep(BWGap_brate) dec(3) nocons nor2  replace 



*Hypothesis tests
tab state_bir, gen(STATE_)
foreach s of numlist 1/48 {
g ST_COH_`s'=STATE_`s'*cohort
}

local demconts="fem0 fem1 c.age1##c.age1##c.age1 c.age0##c.age0##c.age0 " 
local cohort_statechars="c.totpop1960##cohort c.landarea1960##cohort c.pcturban1960##cohort c.mededuc1960##cohort c.medinc1960##cohort c.pctblack1960##cohort"


***BASELINE***
*hgc
qui reg  BWGap_hgc BWGap_brate i.cohort STATE* `demconts'  if south==1
est sto ed_s
qui reg  BWGap_hgc BWGap_brate i.cohort STATE* `demconts'  if south==0
est sto ed_n
qui suest ed_s ed_n, vce(cluster state_bir)
test [ed_s_mean]BWGap_brate - [ed_n_mean]BWGap_brate = 0

*log inc
qui reg  log_incgap BWGap_brate i.cohort STATE* `demconts'  if south==1
est sto inc_s
qui reg  log_incgap BWGap_brate i.cohort STATE* `demconts'  if south==0
est sto inc_n
qui suest inc_s inc_n, vce(cluster state_bir)
test [inc_s_mean]BWGap_brate - [inc_n_mean]BWGap_brate = 0



***STATE-SPECIFIC COHORT TRENDS***
*hgc
qui reg  BWGap_hgc BWGap_brate i.cohort STATE* ST_COH_*  `demconts' if south==1
est sto ed_s
qui reg  BWGap_hgc BWGap_brate i.cohort  STATE* ST_COH_* `demconts'  if south==0
est sto ed_n
qui suest ed_s ed_n, vce(robust)
test [ed_s_mean]BWGap_brate - [ed_n_mean]BWGap_brate = 0

*log inc
qui reg  log_incgap BWGap_brate i.cohort STATE* ST_COH_* `demconts'   if south==1
est sto inc_s
qui reg  log_incgap BWGap_brate i.cohort STATE* ST_COH_* `demconts'  if south==0
est sto inc_n
qui suest inc_s inc_n, vce(robust)
test [inc_s_mean]BWGap_brate - [inc_n_mean]BWGap_brate = 0



***STATE CHARS BY COHORT EFFECTS***
*hgc
qui reg  BWGap_hgc BWGap_brate i.cohort STATE* `cohort_statechars' `demconts' if south==1
est sto ed_s
qui reg  BWGap_hgc BWGap_brate i.cohort STATE* `cohort_statechars' `demconts'  if south==0
est sto ed_n
qui suest ed_s ed_n, vce(robust)
test [ed_s_mean]BWGap_brate - [ed_n_mean]BWGap_brate = 0

*log inc
qui reg  log_incgap BWGap_brate i.cohort STATE* `cohort_statechars' `demconts'   if south==1
est sto inc_s
qui reg  log_incgap BWGap_brate i.cohort STATE* `cohort_statechars' `demconts'  if south==0
est sto inc_n
qui suest inc_s inc_n, vce(robust)
test [inc_s_mean]BWGap_brate - [inc_n_mean]BWGap_brate = 0






***Table 4: DFL Reweighting in NLSY79***
use nlsy79working, clear
keep if bornsouth==1 

reg momhgc birth_order black hgc_ever logearnings afqtz  farm [aweight=weight]
keep if e(sample)==1


probit black i.birth_order i.momhgc farm [pweight=weight]
predict pblack
sum black [aweight=weight]
g dflweight=(pblack*`r(mean)') / ((1-pblack)*(1-`r(mean)'))
replace dflweight=1 if black==1
g probweight=dflweight*weight

foreach x of varlist momhgc momed8 birth_order high_border farm hgc_ever logearnings afqtz { 
qui reg `x' black [aweight=weight], robust
scalar `x'_base=_b[black]
est sto `x'_base

qui reg `x' black 	[aweight=probweight], robust
scalar `x'_rw=_b[black]
est sto `x'_reweighted

scalar `x'change=`x'_base-`x'_rw

}
outreg2 [*] using T1,  nocons nor2 dec(2) replace
scalar list hgc_everchange logearningschange afqtzchange




***Figure A10: DFL Nonparametric for Earnings***
use nlsy79working, clear
keep if bornsouth==1 

reg momhgc birth_order black hgc_ever logearnings afqtz [aweight=weight]
keep if e(sample)==1

probit black i.birth_order i.momhgc [pweight=weight]
predict pblack
sum black [aweight=weight]
g dflweight=(pblack*`r(mean)') / ((1-pblack)*(1-`r(mean)'))
replace dflweight=1 if black==1
g probweight=dflweight*weight

pctile pctile_black = logearnings if black==1 [aweight=weight], n(100)
pctile pctile_white = logearnings if black==0 [aweight=weight], n(100)
pctile pctile_white_counter = logearnings if black==0 [aweight=probweight], n(100)

keep pctile*
keep in 1/99
g gap=pctile_white-pctile_black
g gap_counter=pctile_white_counter-pctile_black
g change=gap-gap_counter
g percentile=_n

twoway lpoly gap  percentile, lpattern(solid) lcolor(gs1) || lpoly gap_counter  percentile, lpattern(dash) lcolor(gs1) || lpoly change  percentile, lpattern(dot) lcolor(gs1) ///
legend(label(1 "Unconditional Gap") label(2 "Counterfactual Gap") label(3 "|Change|") rows(1) region(margin(small))) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  ///
xtitle(Percentile)  title(Figure A10: DFL Decomposition for Log Earnings) saving(earnings, replace)





***Figure A11: DFL Nonparametric for AFQT***
use nlsy79working, clear
keep if bornsouth==1 

reg momhgc birth_order black hgc_ever logearnings afqtz [aweight=weight]
keep if e(sample)==1

probit black i.birth_order i.momhgc [pweight=weight]
predict pblack
sum black [aweight=weight]
g dflweight=(pblack*`r(mean)') / ((1-pblack)*(1-`r(mean)'))
replace dflweight=1 if black==1
g probweight=dflweight*weight

pctile pctile_black = afqtz if black==1 [aweight=weight], n(100)
pctile pctile_white = afqtz if black==0 [aweight=weight], n(100)
pctile pctile_white_counter = afqtz if black==0 [aweight=probweight], n(100)

keep pctile*
keep in 1/99
g gap=pctile_white-pctile_black
g gap_counter=pctile_white_counter-pctile_black
g change=gap-gap_counter
g percentile=_n

twoway lpoly gap  percentile, lpattern(solid) lcolor(gs1) || lpoly gap_counter  percentile, lpattern(dash) lcolor(gs1) || lpoly change  percentile, lpattern(dot) lcolor(gs1) ///
legend(label(1 "Unconditional Gap") label(2 "Counterfactual Gap") label(3 "|Change|") rows(1) region(margin(small))) ///
graphregion(ifcolor(white) fcolor(white) lcolor(white) icolor(white))  ///
xtitle(Percentile)  title(Figure A11: DFL Decomposition for AFQT Scores) saving(afqt, replace)




